﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class GaussianBlurEffectData : EffectOneSourceData
    {
        #region  属性

        private float _blurAmount=3;
        /// <summary>
        /// 获取或设置模糊量
        /// </summary>
        public float BlurAmount { get { return _blurAmount; } set { _blurAmount = value; OnPropertyChanged(); SetIsChanges(); } }

        /// <summary>
        /// 获取或设置边缘模式
        /// </summary>
        public EffectBorderMode BorderMode { get => _borderMode; set { _borderMode = value; OnPropertyChanged();SetIsChanges(); } }
        /// <summary>
        /// 获取或设置优化类型
        /// </summary>
        public EffectOptimization Optimization { get => _optimization; set { _optimization = value;OnPropertyChanged();SetIsChanges(); } }

        private EffectBorderMode _borderMode= EffectBorderMode.Soft;

        private EffectOptimization _optimization = EffectOptimization.Speed;
        #endregion

        public override ICanvasImage GetEffect(CanvasDevice device, bool compression )
        {
           var source = GetSourceEffect(device, compression);
            if(source == null)
            {
                return null;
            }

         
            GaussianBlurEffect gbe = new GaussianBlurEffect()
            {
                BlurAmount = BlurAmount,
                BorderMode = BorderMode,
                Optimization = Optimization,
                Source = source,
            };
         
       
        
            
            return gbe;
        }
    }
}
